package helper;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.swing.JOptionPane;

public class DateHelper {
    public static Calendar pegarDiaAtual(){
        Calendar dataAtual = Calendar.getInstance();
        dataAtual.setTime(new Date());
        DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
        try {
            dataAtual.setTime(df.parse(df.format(dataAtual.getTime())));
        } catch (ParseException ex) {
            JOptionPane.showMessageDialog(null, ex);
        }   
        return dataAtual;
    }
    
    public static String formatarData(Calendar data){
        Calendar dataFormatada = data;
        DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
        return df.format(dataFormatada);
    }
    
    public static String formatarData(String formato, Calendar data) {
        return new SimpleDateFormat(formato).format(data.getTime());
    }

    public static String formatarDataMysql(Calendar data) {
        return new SimpleDateFormat("dd/MM/yyyy").format(data.getTime());
    }

    public static String formatarDataMysql(Date data) {
        return new SimpleDateFormat("dd/MM/yyyy").format(data.getTime());
    }
    
}
